package com.wltt.product.frfront.utils.http5;

public enum HttpMethodEnum {

    GET(1, "GET"),
    HEAD(2, "HEAD"),
    POST(3, "POST"),
    PUT(4, "PUT"),
    PATCH(5, "PATCH"),
    DELETE(6, "DELETE"),
    OPTIONS(7, "OPTIONS"),
    TRACE(8, "TRACE");

    HttpMethodEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 获取方法常量
     *
     * @param method        调用方法
     */
    public static HttpMethodEnum get(String method) {
        if (HttpMethodEnum.GET.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.GET;
        } else if (HttpMethodEnum.HEAD.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.HEAD;
        } else if (HttpMethodEnum.POST.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.POST;
        } else if (HttpMethodEnum.PUT.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.PUT;
        } else if (HttpMethodEnum.PATCH.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.PATCH;
        } else if (HttpMethodEnum.DELETE.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.DELETE;
        } else if (HttpMethodEnum.OPTIONS.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.OPTIONS;
        } else if (HttpMethodEnum.TRACE.getDesc().equalsIgnoreCase(method)) {
            return HttpMethodEnum.TRACE;
        }
        throw new RuntimeException("不支持的http方法");
    }

    private Integer code;
    private String desc;


    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
